package com.sz.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.gcord.gcorddemo.R;
import com.sz.main.DailListActivity;
import com.sz.main.Setting;
import com.sz.widget.ImageTextButton;

public class HomeFragment extends Fragment implements View.OnClickListener {
    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_home, null);
        initView();
        return view;
    }

    private void initView() {
        if (view == null)
            return;

        ImageTextButton infoBtn = (ImageTextButton) view.findViewById(R.id.infoBtn);
        ((TextView) infoBtn.findViewById(R.id.text)).setText("信息告警");
        infoBtn.findViewById(R.id.image).setBackgroundResource(R.drawable.info);
        infoBtn.findViewById(R.id.img_text_item_layout).setBackgroundResource(R.drawable.green_button);
        infoBtn.setOnClickListener(this);

        ImageTextButton awosBtn = (ImageTextButton) view.findViewById(R.id.awosBtn);
        ((TextView) awosBtn.findViewById(R.id.text)).setText("自观告警");
        awosBtn.findViewById(R.id.image).setBackgroundResource(R.drawable.awos);
        awosBtn.findViewById(R.id.img_text_item_layout).setBackgroundResource(R.drawable.blue_button);
        awosBtn.setOnClickListener(this);

        ImageTextButton radarBtn = (ImageTextButton) view.findViewById(R.id.radarBtn);
        ((TextView) radarBtn.findViewById(R.id.text)).setText("雷达告警");
        radarBtn.findViewById(R.id.image).setBackgroundResource(R.drawable.radar);
        radarBtn.findViewById(R.id.img_text_item_layout).setBackgroundResource(R.drawable.black_button);
        radarBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.infoBtn:
                Intent intent = new Intent(getActivity(), DailListActivity.class);
                startActivity(intent);
                break;
        }
    }
}

